package com.wangmei.service.serviceimpl;

import com.wangmei.mapper.AttributeMapper;
import com.wangmei.mapper.AttributevalueMapper;
import com.wangmei.model.Attribute;
import com.wangmei.model.Attributevalue;
import com.wangmei.pojo.AttributePojo;
import com.wangmei.pojo.AttributeViewPojo;
import com.wangmei.service.AttributeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional
public class AttributeServiceImpl implements AttributeService {
    @Autowired
    private AttributeMapper attributeMapper;
    @Autowired
    private AttributevalueMapper attributevalueMapper;

    @Override
    public List<AttributeViewPojo> getAttributeByCid(Map map) {
        return attributeMapper.getAttributeByCid(map);
    }

    @Override
    public Attributevalue getAttributevalueByVname(String vname) {
        return attributevalueMapper.getAttributevalueByVname(vname);
    }

    @Override
    public int addAttributevalue(Attributevalue attributevalue) {
        return attributevalueMapper.insertSelective(attributevalue);
    }

    @Override
    public AttributePojo getAttributePojoByCid(int cid) {
        return attributeMapper.getAttributePojoByCid(cid);
    }

    @Override
    public int getVidByVnameAid(String vname,int aid) {
        Attributevalue a = attributevalueMapper.getAttributevalueByVnameAid(vname,aid);
        Integer vid = a.getVid();
        return vid;
    }

    @Override
    public List<Attribute> getAttributeList(int cid) {
        return attributeMapper.getAttributeListByCid(cid);
    }

    @Override
    public List<Attributevalue> getAttvalueByAid(int aid) {
        return attributevalueMapper.getAttvalueListByAid(aid);
    }


}
